package com.google.code.yargon.level;

import com.google.code.yargon.engine.Cast;
import static com.google.code.yargon.util.Constants.*;

/**
 * A simple class storing direction
 * @author Mika Myllynen
 *
 */
public class Direction {
	
	private int direction;
	
	/**
	 * New direction
	 * 
	 * @param direction
	 */
	public Direction(int direction) {
		this.direction = direction;
	}
	
	/**
	 * Get the direction
	 * 
	 * @return
	 */
	public int getDirection() {
		return this.direction;
	}
	
	/**
	 * Set the direction
	 * 
	 * @param direction
	 */
	public void setDirection(int direction) {
		this.direction = direction;
	}
	
	/**
	 * Get a random direction
	 * 
	 * @return
	 */
	public static Direction getRandomDirection() {
		return new Direction(Cast.castFromSet(NORTH, EAST, SOUTH, WEST));
	}
	
	/**
	 * Return the direction as a string
	 * 
	 */
	public String toString() {
		switch(this.direction) {
		case NORTH: return "N";
		case EAST: return "E"; 
		case SOUTH: return "S"; 
		case WEST: return "W"; 
		case NORTH_EAST: return "NE"; 
		case SOUTH_EAST: return "SE"; 
		case SOUTH_WEST: return "SW"; 
		case NORTH_WEST: return "NW"; 
		}
		
		return "Undefined";
	}
}
